<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="/web3/cs_login/jquery-3.2.0.min.js"></script>

<script type="text/javascript">
	function getValue() {
		var nickName = $("#nickName").val();
		var passwd = $("input[name='passwd']").val();
		var intro = $("textarea[name='intro']").val();
		
		var isChecked = $("input[name='sex']:checked").val();  
	    var radio1 = $("input[name='sex']:eq(0)").attr("checked"); 
	    var radio2 = $("input[name='sex']:eq(1)").attr("checked"); 
		    
		alert(nickName+"---"+passwd+"---"+intro);
	}

	function setValue() {
		$("#nickName").val("hello");
		$("input[name='passwd']").val("09876543")
		$("textarea[name='intro']").val("设置一个值");
		$("input[name='email']").val("aa@163.com");
		$("input[name='sex']:eq(1)").attr("checked",true); 
	}
	
	function verify() {
		var nickName = $("#nickName").val();
		if (nickName == '') {
			$("#nickNameErr").show();
			return false;
		}
		
		var email = $("input[name='email']").val();
		var reg = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{2,3}){1,2})$/;
	    if (!reg.test(email)) {
	        alert('邮箱格式不正确，请重新填写!');
	       return false;
	  	}
	    
	   return true;
	}
</script>
</head>
<body>
	<form id="frm" action="/web3/UserDetailInsert" method="post" onsubmit="return verify()">
		昵称：<input type="text" id="nickName" name="nickName"><div id="nickNameErr" style="display:none;color:red">请填写昵称</div> <br>
		邮箱:<input type="text" name="email"><br>
		密码:<input type="password" name="passwd"><br>
		简介：<textarea rows="5" cols="50" name="intro"></textarea><br>
		<input type="radio" name="sex" value="0">女
		<input type="radio" name="sex" value="1">男<br>
		<input type="submit" value="新增">
		<input type="button" value="设置值" onclick="setValue()">
		<input type="button" value="获取值" onclick="getValue()">
		
	</form>
</body>
</html>